import { container, singleton } from "tsyringe";
import { RobotAppPage } from "../../page";
import { Task } from "../../../autox/task";
import { $ } from "../../../utils";

@singleton()
export class GqcActivity extends RobotAppPage {
    title: string = `弹框gqc.a`
    private isRuning: boolean = false;
    private task: Task;
    constructor() {
        super();
        this.task = container.resolve(Task)
    }
    dispose(): void {
        this.out()
    }
    is(packageName: string): boolean {
        return `com.smile.gifmaker` === packageName|| `com.kuaishou.nebula` === packageName;
    }
    accept(activityName: string): boolean {
        return `s74.l` === activityName;
    }
    in(): boolean {
        if (this.isRuning) return;
        this.isRuning = true;
        /**
         * 复制链接
         */
        const node = text('复制链接').visibleToUser(true).findOne()
        if (node) {
            $.clickButton(node)
        }
        return true;
    }
    back() {
        sleep(500)
        back();
        sleep(500)
    }
    out(): boolean {
        if (!this.isRuning) return false;
        this.isRuning = false;
        return true;
    }
}